﻿<Page x:Class="EduAssess.Views.StatisticsPage"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
      DataContext="{Binding Source={StaticResource ViewModelLocator}, Path=StatisticsPageViewModel}"
      mc:Ignorable="d"
      Title="StatisticsPage" Height="450" Width="800">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="auto"/>
            <RowDefinition Height="auto"/>
            <RowDefinition Height="auto"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="auto"/>
        </Grid.RowDefinitions>

        <TextBlock Text="Результаты"
                   TextAlignment="Center"
                   Padding="7"
                   FontWeight="Bold"
                   FontSize="20"/>

        <TextBlock Text="Правильные/Неправильные ответы:"
                   Grid.Row="1"
                   TextAlignment="Center"
                   Padding="7"/>

        <ProgressBar Grid.Row="2"
                     Minimum="0"
                     Maximum="100"
                     Value="{Binding Result}"
                     MinHeight="25"
                     Padding="10"
                     Margin="200,5"
                     Background="Red"
                     FontWeight="Bold"
                     Name="PbStatus"/>

        <TextBlock Text="{Binding ElementName=PbStatus, Path=Value, StringFormat={}{0:0}%}"
                   HorizontalAlignment="Center"
                   VerticalAlignment="Center"
                   Grid.Row="2"/>

        <ScrollViewer Grid.Row="3">
            <ItemsControl ItemsSource="{Binding Questions}" >
                <ItemsControl.ItemTemplate>
                    <DataTemplate>
                        <StackPanel>
                            <TextBlock Text="{Binding Name}"
                                       TextWrapping="Wrap"
                                       Padding="2"
                                       TextAlignment="Left"/>
                            <ItemsControl ItemsSource="{Binding Answers}">
                                <ItemsControl.ItemTemplate>
                                    <DataTemplate>
                                        <WrapPanel Orientation="Horizontal">
                                            <RadioButton IsChecked="{Binding IsTrue}"
                                                         IsEnabled="False"
                                                         Padding="2">
                                                <TextBlock Text="{Binding Name}"
                                                        TextWrapping="Wrap"
                                                        TextAlignment="Left">
                                                </TextBlock>
                                            </RadioButton>
                                        </WrapPanel>
                                    </DataTemplate>
                                </ItemsControl.ItemTemplate>
                            </ItemsControl>
                        </StackPanel>
                    </DataTemplate>
                </ItemsControl.ItemTemplate>
            </ItemsControl>

        </ScrollViewer>

        <UniformGrid Columns="3"
                     Grid.Row="4">
            <Button Content="Правильные ответы"
                    Padding="5"
                    Margin="10,5"
                    Command="{Binding ShowRightQuestions}"/>
            <Button Content="Неправильные ответы"
                    Padding="5"
                    Margin="10,5"
                    Command="{Binding ShowWrongQuestions}"/>
            <Button Content="В главное меню"
                    Padding="5"
                    Margin="10,5"
                    Command="{Binding ToStartPage}"/>
        </UniformGrid>
    </Grid>
</Page>
